package spring.superrun.record.mvc.setup;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisCluster;
@Configuration
public class JedisClusterConfig {

    /**
     * 获取jedis链接
     *
     * @return
     */
    @Bean
    public Jedis redisClient() {
        try {
//            Set<HostAndPort> nodes = new HashSet<>();
//            String[] hostArray = _redisConfig.getHosts().split(",");
//            for (String host : hostArray) {
//                String[] ipAndPort = host.split(":");
//                nodes.add(new HostAndPort(ipAndPort[0], Integer.parseInt(ipAndPort[1])));
//            }
            Jedis cluster = new Jedis("127.0.0.1",6379);
            return cluster;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
